package com.guoguo.base;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.guoguo.utils.JsonUtils;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/9 0009.
 */
public class BaseController {

    /**
     * 返回json参数
     *
     * @param msgCode
     * @param data
     * @param msg
     * @return
     */
    public JSONObject returnResult(Integer msgCode, Object data, String msg) {
        return JsonUtils.returnObject(msgCode, data, msg);
    }

    /**
     * 返回页面数据
     *
     * @param path
     * @param result
     * @return
     */
    public ModelAndView returnView(String path, Map<String, Object> result) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName(path);
        modelAndView.addAllObjects(result);
        return modelAndView;
    }
}
